//
//  SubModel.m
//  EducationAdminClient
//
//  Created by 孙添凤 on 17/1/24.
//  Copyright © 2017年 周佳兴. All rights reserved.
//

#import "SubModel.h"

@implementation SubModel

+(JSONKeyMapper*)keyMapper {
    
    /* 注意JuhuiModel里面需要映射2种类型
     1. 驼峰Camel命名规范
     2. 把author.header_img和author_username要映射到JuhuiModel直接字段里面 */
    JSONKeyMapper *mapper = [JSONKeyMapper mapperFromUnderscoreCaseToCamelCase];
    // 取得影射的blocks对象
    JSONModelKeyMapBlock modelBlock = mapper.modelToJSONKeyBlock;
    
    // 根据上述的重新创建映射条件
    JSONKeyMapper *newMapper = [[JSONKeyMapper alloc] initWithJSONToModelBlock:nil modelToJSONBlock:^NSString *(NSString *keyName) {
        // 告诉我们影射规律
        if ([keyName isEqualToString:@"classNum"]) {
            return @"classNum";
        } else if ([keyName isEqualToString:@"courseName"]) {
            return @"courseName";
        } else if ([keyName isEqualToString:@"teacherName"]) {
            return @"teacherName";
        } 
        return modelBlock(keyName);
    }];
    return newMapper;
    
    
    //return [JSONKeyMapper mapperFromUnderscoreCaseToCamelCase];
}


+(BOOL)propertyIsOptional:(NSString*)propertyName {
    return  YES;
}


@end
